package com.system.member.controller;


import com.system.common.context.LoginMemberContext;
import com.system.common.resp.CommonResp;
import com.system.common.resp.PageResp;
import com.system.member.req.PassengerQueryReq;
import com.system.member.req.PassengerSaveReq;
import com.system.member.resp.PassengerQueryResp;
import com.system.member.service.PassengerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/passenger")
public class PassengerController {

    @Autowired
    private PassengerService passengerService;

    @PostMapping("save")
    public CommonResp<Object> save(@Valid @RequestBody PassengerSaveReq req) {
        passengerService.saveOrUpdate(req);
        return new CommonResp<>();
    }

    @GetMapping("/query-list")
    public CommonResp<PageResp<PassengerQueryResp>> queryList(@Valid PassengerQueryReq req) {
        System.out.println("req::::"+req);
        req.setMemberId(1769936433117794304l);
        PageResp<PassengerQueryResp> list = passengerService.queryList(req);
        return new CommonResp<>(list);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        passengerService.removeById(id);
        return new CommonResp<>();
    }
    @GetMapping("test")
    public String test(){
        return "Success";
    }

    @GetMapping("/query-mine")
    public CommonResp<List<PassengerQueryResp>> queryMine() {
        List<PassengerQueryResp> list = passengerService.queryMine();
        return new CommonResp<>(list);
    }
}
